<?php
require('Header.php');
?>      

    <?php  
    // Retrieve array of friends who've already added the app.  
    $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$fb_user.') AND has_added_app = 1'; 
    $_friends = $facebook->api_client->fql_query($fql); 
     
    // Extract the user ID's returned in the FQL request into a new array.  
    $friends = array();  
    if (is_array($_friends) && count($_friends)) {  
        foreach ($_friends as $friend) {  
           $friends[] = $friend['uid'];  
       }  
   }  
     
   // Convert the array of friends into a comma-delimeted string.  
   $friends = implode(',', $friends);  
     
   // Prepare the invitation text that all invited users will receive.  
   $content = <<<FBML
   <fb:name uid="{$fb_user}" firstnameonly="true" shownetwork="false"/> wants you to be a part of Small World!  
   <fb:req-choice url="{$facebook->get_add_url()}" label="Add Small World to your profile!"/>
FBML;
?>  
   <fb:request-form action="http://apps.facebook.com/smallsmallworld/" method="POST" invite="true" type="Small World" content="<?php echo htmlentities($content);?>">  
   <fb:multi-friend-selector max="20" actiontext="Here are your friends who haven't added Small World. Invite them to Small World today!" showborder="true" rows="5" exclude_ids="<?php echo $friends;?>"></fb:request-form>
